<template>
	<center class="model">
		<div class="model-head">
			<img src="../../../static/img/yamiloco.svg" />
		</div>
		<div class="model-body" @click="weixinLogin">
			<img src="../../../static/img/weixinlogo.svg" />
			<span>微信登陆</span>
		</div>
	</center>
</template>

<script>
	import server from '@/server/api';
	import { Toast } from 'mint-ui';
	import { mapGetters, mapState, mapActions } from 'vuex';
	export default {
		data() {
			return {}
		},
		computed: {
			...mapState(['userInfo'])
		},
		mounted() {},
		methods: {
			...mapActions(['getUserInfo']),
			weixinLogin() {
//				var _this = this
//				_this.getUserInfo({
//					openid: "oRrdQt0sqjccSYDbt7xO7lbra49E",
//					nickname: "。",
//					sex: 1,
//					language: "zh_CN",
//					city: "厦门",
//					province: "福建",
//					country: "中国",
//					headimgurl: "http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLZQtgUL0YiaN1iaBBsbibYE9HibbvYfFhw7Hxx0pnaOtcTk0Dd6t9UhVIW5JPw9ibs4fkViaTmPAvdicGtA/132",
//					privilege: [],
//					unionid: "oU5Yyt02gaBgZmoZF0dnLIxQNI_c"
//				})
//				_this.$emit("showWeixinLogin", false)
//				return;

				var s;
				auths.map(function(ele) {
					if(ele.id == "weixin") {
						s = ele;
					}
				})
				var _this = this;
				if(!s.authResult) {
					// 登陆微信
					s.login(function(e) {
						Toast("登录认证成功！");
						_this.$emit("showWeixinLogin", false)
						// 获取个人信息
						s.getUserInfo(function(e) {
							//							console.log(JSON.stringify(s.userInfo))
//							server.post("/index/Weixinlogin/verify_login", s.userInfo, function(res) {
//								console.log(JSON.stringify(res))
//							})
//							_this.$store.state.userInfo = s.userInfo;
							_this.getUserInfo(s.userInfo)
						}, function(e) {});
					}, function(e) {
						Toast("登录认证失败！");
					});
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.model {
		width: 660px;
		height: 340px;
		background-color: #FFFFFF;
		.model-head {
			height: 200px;
			img {
				width: 160px;
				margin-top: 60px;
			}
		}
		.model-body {
			width: 540px;
			height: 88px;
			border-radius: 44px;
			background-image: linear-gradient(-180deg, #F64565 0%, #EF364E 100%);
			font-size: 32px;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: center;
			span {
				margin-left: 10px;
			}
			img {
				width: 44px;
			}
		}
	}
</style>